package com.bjpowernode.javase.exception;
/*
测试改良之后的栈
 */
public class ExceptionTest16 {
    public static void main(String[] args) {
        //创建栈对象
        Mystack stack = new Mystack();

        //压栈
        try{
            stack.push(new Object());
            stack.push(new Object());
            stack.push(new Object());
            stack.push(new Object());
            stack.push(new Object());
            stack.push(new Object());
            stack.push(new Object());
            stack.push(new Object());
            stack.push(new Object());
            stack.push(new Object());
            //这里栈满
            stack.push(new Object());
        }catch(MyStackOperationException e){
            //e.printStackTrace();
            //输出异常的简单信息
            System.out.println(e.getMessage());
        }

        //弹栈
        try {
            stack.pop();
            stack.pop();
            stack.pop();
            stack.pop();
            stack.pop();
            stack.pop();
            stack.pop();
            stack.pop();
            stack.pop();
            stack.pop();
            //栈已空。
            stack.pop();
        } catch (MyStackOperationException e) {
            //e.printStackTrace();
            System.out.println(e.getMessage());
        }
    }



}
